$(document).ready(function () {
    // if(getCookie('code')==202){

    // }else if(getCookie('code')==201){

    // }else{
    //     window.location.href="login.html"
    // }
    $('#body2-top h2').html(getCookie('formwork-h2'))
    $('#body2-top p').html(getCookie('formwork-p'))
    $('#body2-top-span1').html(getCookie('formwork-span1'))
    $('#body2-top-span2').html(getCookie('formwork-span2'))
    $('#body2-top-span3').html(getCookie('formwork-span3'))
    $('#body2-top-span4').html(getCookie('formwork-span4'))
    $('#body2-top-span5').html(getCookie('formwork-span5'))
    $('#body2-top-span6').html(getCookie('formwork-span6'))

    var body2_divbuttom = parseInt($('#body2-middle-buttom').css('height'))
    $.ajax({
        type: "GET",
        url: "js/test.json",
        success: function (data) {
            var a= function(){
                for (var i = 0; i < data.result.length; i++) {
                    $('#formwork-ol-1').append(
                        '<div><p>' + (i + 1) + '. ' + data.result[i].header + '</p>' +
                        '<p style="margin-bottom:10px">' +
                        '<span>' + data.result[i].bodyA + '</span>' +
                        '<span>' + data.result[i].bodyB + '</span>' +
                        '<span>' + data.result[i].bodyC + '</span>' +
                        '<span>' + data.result[i].bodyD + '</span>' +
                        '</p></div>'
                    )
                    var body2_pwrap = parseInt($('#body2-middle-buttom-div').css('height'))
                    var body2_lastdiv = parseInt($('#formwork-ol-1 div:last').css('height'))
                    if (body2_lastdiv > body2_divbuttom - body2_pwrap - 29) {
                        setCookie('formwork-body2-i',i)
                        return 
                    }
                }
            }
            a();
            for (var i = parseInt(getCookie('formwork-body2-i'))+1; i < data.result.length; i++) {
                $('#formwork-ol-2').append(
                    '<p style="margin-top:10px">' + (i+1) + '. ' + data.result[i].header + '</p>' +
                    '<p>' +
                    '<span>' + data.result[i].bodyA + '</span>' +
                    '<span>' + data.result[i].bodyB + '</span>' +
                    '<span>' + data.result[i].bodyC + '</span>' +
                    '<span>' + data.result[i].bodyD + '</span>' +
                    '</p>'
                )
            }


        },
        error: function (data) {
            console.log(error)
        }
    })

})